package com.coffee.service.impl;

import com.coffee.conmmon.BaseResult;
import com.coffee.dao.ScardsMapper;
import com.coffee.entity.Scards;
import com.coffee.entity.ScardsScardss;
import com.coffee.service.ScardsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScardsServiceImpl implements ScardsService {
    @Autowired
    private ScardsMapper scardsMapper;
    @Override
    public BaseResult findAll() {
        List<Scards> all = scardsMapper.findAll();
        BaseResult baseResult = new BaseResult();
        if (all!=null){
            baseResult.setCode(200);
            baseResult.setMessage("查询成功");
            baseResult.setData(all);
            return baseResult;
        }else {
            baseResult.setCode(201);
            baseResult.setMessage("查询失败");
            return baseResult;
        }

    }

    @Override
    public BaseResult findByCid(Integer cid) {
        ScardsScardss byCid = scardsMapper.findByCid(cid);
        BaseResult baseResult = new BaseResult();
        if (byCid!=null){
            baseResult.setData(byCid);
            baseResult.setMessage("查询成功");
            baseResult.setCode(200);
            return baseResult;
        }else{
            baseResult.setCode(201);
            baseResult.setMessage("查询失败");
            return baseResult;
        }
    }
}
